package cn.IT.service.impl;

import java.io.Serializable;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.IT.dao.IKnowledgeDAO;
import cn.IT.dao.IUserDAO;
import cn.IT.domain.Approve;
import cn.IT.domain.Knowledge;
import cn.IT.domain.Type;
import cn.IT.domain.User;
import cn.IT.service.IKnowledgeService;
import cn.IT.service.IUserService;

@Service(value = "knowledgeService")
@SuppressWarnings("all")
@Transactional
public class KnowledgeService implements IKnowledgeService {

	@Resource
	private IKnowledgeDAO knowledgeDAO;
	
	@Override
	public List<Knowledge> getAllKnowledgeBySearchContent(String searchContent) {
		return knowledgeDAO.getAllKnowledgeBySearchContent(searchContent);
	}

	@Override
	public List<Knowledge> getAllKnowledgeByAuthor(User user) {
		List<Knowledge> knowledges = knowledgeDAO.getAllKnowledgeByAuthor(user);
		if(knowledges != null){
			Collections.reverse(knowledges);
		}
		return knowledges;
	}

	@Override
	public List<Knowledge> getAllKnowledgeByType(Type type) {
		return knowledgeDAO.getAllKnowledgeByType(type);
	}

	@Override
	public Knowledge getKnowledgeById(Serializable knowledgeId) {
		return knowledgeDAO.get(Knowledge.class, knowledgeId);
	}
	
	@Override
	public Integer getKnowledgeCount() {
		return knowledgeDAO.findAll(Knowledge.class).size();
	}
	
	
	
	


}
